/**
 * 
 */
package com.chinamobile.maps.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.chinamobile.maps.dao.INetworktypesDAO;
import com.chinamobile.maps.orm.Channelnetworks;
import com.chinamobile.maps.orm.Networktypes;

/**
 * @author FrankWong
 *
 */
public class NetworktypesDAOImpl extends HibernateDaoSupport implements
		INetworktypesDAO {

	/* (non-Javadoc)
	 * @see com.chinamobile.maps.dao.INetworktypesDAO#addNetworktypes(com.chinamobile.maps.orm.Networktypes)
	 */
	@Override
	public void addNetworktypes(Networktypes networktypes) {
		this.getHibernateTemplate().save(networktypes);
	}

	/* (non-Javadoc)
	 * @see com.chinamobile.maps.dao.INetworktypesDAO#delNetworktypes(com.chinamobile.maps.orm.Networktypes)
	 */
	@Override
	public void delNetworktypes(Networktypes networktypes) {
		this.getHibernateTemplate().delete(networktypes);
	}

	/* (non-Javadoc)
	 * @see com.chinamobile.maps.dao.INetworktypesDAO#delNetworktypes(int)
	 */
	@Override
	public void delNetworktypes(int id) {
		this.getHibernateTemplate().delete(getNetworktypesById(id));
	}

	/* (non-Javadoc)
	 * @see com.chinamobile.maps.dao.INetworktypesDAO#updateNetworktypes(com.chinamobile.maps.orm.Networktypes)
	 */
	@Override
	public void updateNetworktypes(Networktypes networktypes) {
		this.getHibernateTemplate().update(networktypes);
	}

	/* (non-Javadoc)
	 * @see com.chinamobile.maps.dao.INetworktypesDAO#getNetworktypes()
	 */
	@Override
	public List<Networktypes> getNetworktypes() {
		List list = this.getHibernateTemplate().find("from Networktypes");
		if (list != null && list.size() > 0) {
			return list;
		}
		return null;
	}

	/* (non-Javadoc)
	 * @see com.chinamobile.maps.dao.INetworktypesDAO#getChannelnetworksById(int)
	 */
	@Override
	public Networktypes getNetworktypesById(int id) {
		List list = this.getHibernateTemplate().find("from Networktypes as networktypes where networktypes.id=?",
				new Object[] { id });

		if (list != null && list.size() > 0) {
			return (Networktypes) list.get(0);
		}
		return null;
	}
}
